return TRUE;
}
-static void
-gdk_directfb_draw_rectangle (GdkDrawable *drawable,
- GdkGC *gc,
- gint filled,
- gint x,
- gint y,
- gint width,
- gint height)
-{
- GdkDrawableImplDirectFB *impl;
- cairo_region_t clip;
- GdkGCDirectFB *gc_private = NULL;
- IDirectFBSurface *surface = NULL;
- gint i;
-
- g_return_if_fail (GDK_IS_DRAWABLE (drawable));
-
- D_DEBUG_AT( GDKDFB_Drawable, "%s( %p, %p, %s, %4d,%4d - %4dx%4d )\n", G_STRFUNC,
- drawable, gc, filled ? " filled" : "outline", x, y, width, height );
-
- impl = GDK_DRAWABLE_IMPL_DIRECTFB (drawable);
-
- if (!impl->surface)
- return;
-
- if (gc)
- gc_private = GDK_GC_DIRECTFB (gc);
-
- if (gc_private)
- {
- if (gdk_directfb_enable_color_keying &&
- (gc_private->values.foreground.red >> 8) == gdk_directfb_bg_color_key.r &&
- (gc_private->values.foreground.green >> 8) == gdk_directfb_bg_color_key.g &&
- (gc_private->values.foreground.blue >> 8) == gdk_directfb_bg_color_key.b)
- {
- if (DFB_PIXELFORMAT_IS_INDEXED (impl->format))
- impl->surface->SetColorIndex (impl->surface, 255);
- else
- impl->surface->SetColor (impl->surface,
- gdk_directfb_bg_color.r,
- gdk_directfb_bg_color.g,
- gdk_directfb_bg_color.b,
- gdk_directfb_bg_color.a);
- }
- else
- {
- if (!gdk_directfb_setup_for_drawing (impl, gc_private)){
- return;
- }
- }
- }
- else
- {
- GdkWindowObject *win = GDK_WINDOW_OBJECT (impl->wrapper);
-
- if (gdk_directfb_enable_color_keying)
- {
- if (DFB_PIXELFORMAT_IS_INDEXED (impl->format))
- impl->surface->SetColorIndex (impl->surface, 255);
- else
- impl->surface->SetColor (impl->surface,
- gdk_directfb_bg_color.r,
- gdk_directfb_bg_color.b,
- gdk_directfb_bg_color.g,
- gdk_directfb_bg_color.a);
- }
- else
- {
- gdk_directfb_set_color (impl, &win->bg_color, 0xFF);
- }
- }
-
- if (filled)
- {
- GdkRectangle rect = { x, y, width, height };
-
- gdk_directfb_clip_region (drawable, gc, &rect, &clip);
-
- if (gc_private && gc_private->values_mask & GDK_GC_FILL)
- {
- if (gc_private->values.fill == GDK_STIPPLED &&
- gc_private->values_mask & GDK_GC_STIPPLE &&
- gc_private->values.stipple)
- {
- surface = GDK_DRAWABLE_IMPL_DIRECTFB (GDK_PIXMAP_OBJECT (gc_private->values.stipple)->impl)->surface;
-
- if (surface)
- impl->surface->SetBlittingFlags (impl->surface,
- (DSBLIT_BLEND_ALPHACHANNEL |
- DSBLIT_COLORIZE));
- }
- else if (gc_private->values.fill == GDK_TILED &&
- gc_private->values_mask & GDK_GC_TILE &&
- gc_private->values.tile)
- {
- surface = GDK_DRAWABLE_IMPL_DIRECTFB (GDK_PIXMAP_OBJECT (gc_private->values.tile)->impl)->surface;
-
- impl->surface->SetBlittingFlags (impl->surface, DSBLIT_NOFX);
- }
- }
-
- if (surface)
- {
- if (gc_private->values_mask & GDK_GC_TS_X_ORIGIN)
- x = gc_private->values.ts_x_origin;
- if (gc_private->values_mask & GDK_GC_TS_Y_ORIGIN)
- y = gc_private->values.ts_y_origin;
-
- for (i = 0; i < clip.numRects; i++)
- {
- DFBRegion reg = { clip.rects[i].x1, clip.rects[i].y1,
- clip.rects[i].x2, clip.rects[i].y2 };
-
- impl->surface->SetClip (impl->surface, ®);
- impl->surface->TileBlit (impl->surface, surface, NULL, x, y);
- }
- }
- else /* normal rectangle filling */
- {
- DFBRectangle rects[clip.numRects];
-
- impl->surface->SetClip (impl->surface, NULL);
-
- for (i = 0; i < clip.numRects; i++)
- {
- cairo_region_tBox *box = &clip.rects[i];
-
- rects[i].x = box->x1;
- rects[i].y = box->y1;
- rects[i].w = box->x2 - box->x1;
- rects[i].h = box->y2 - box->y1;
- }
-
- impl->surface->FillRectangles(impl->surface, rects, clip.numRects);
- }
-
- temp_region_deinit( &clip );
- }
- else
- {
-
- DFBRegion region = { x, y, x + width, y + height };
- impl->surface->SetClip (impl->surface, ®ion);
-
- /* DirectFB does not draw rectangles the X way. Using DirectFB,
- a filled Rectangle has the same size as a drawn one, while
- X draws the rectangle one pixel taller and wider. */
- impl->surface->DrawRectangle (impl->surface,
- x, y, width , height);
- }
-}
-
static void
gdk_directfb_draw_drawable (GdkDrawable *drawable,
GdkGC *gc,
object_class->finalize = gdk_drawable_impl_directfb_finalize;
drawable_class->create_gc = _gdk_directfb_gc_new;
- drawable_class->draw_rectangle = gdk_directfb_draw_rectangle;
drawable_class->draw_drawable = gdk_directfb_draw_drawable;
drawable_class->ref_cairo_surface = gdk_directfb_ref_cairo_surface;
(gcwin32->line_style == GDK_LINE_DOUBLE_DASH || \
(gcwin32->line_style == GDK_LINE_ON_OFF_DASH && gcwin32->pen_dash_offset))
-static void gdk_win32_draw_rectangle (GdkDrawable *drawable,
- GdkGC *gc,
- gboolean filled,
- gint x,
- gint y,
- gint width,
- gint height);
static void gdk_win32_draw_drawable (GdkDrawable *drawable,
GdkGC *gc,
GdkPixmap *src,
object_class->finalize = gdk_drawable_impl_win32_finalize;
drawable_class->create_gc = _gdk_win32_gc_new;
- drawable_class->draw_rectangle = gdk_win32_draw_rectangle;
drawable_class->draw_drawable_with_src = gdk_win32_draw_drawable;
drawable_class->ref_cairo_surface = gdk_win32_ref_cairo_surface;
g_object_unref (gc_copy);
}
-static void
-generic_draw (GdkDrawable *drawable,
- GdkGC *gc,
- GdkGCValuesMask mask,
- void (*function) (GdkGCWin32 *, HDC, gint, gint, va_list),
- const cairo_region_t *region,
- ...)
-{
- GdkDrawableImplWin32 *impl = GDK_DRAWABLE_IMPL_WIN32 (drawable);
- GdkGCWin32 *gcwin32 = GDK_GC_WIN32 (gc);
- HDC hdc;
- va_list args;
- GdkFill fill_style = _gdk_gc_get_fill (gc);
-
- va_start (args, region);
-
- /* If tiled or stippled, draw to a temp pixmap and do blitting magic.
- */
-
- if (gcwin32->values_mask & GDK_GC_FILL &&
- ((fill_style == GDK_TILED &&
- gcwin32->values_mask & GDK_GC_TILE &&
- _gdk_gc_get_tile (gc) != NULL)
- ||
- ((fill_style == GDK_OPAQUE_STIPPLED ||
- fill_style == GDK_STIPPLED) &&
- gcwin32->values_mask & GDK_GC_STIPPLE &&
- _gdk_gc_get_stipple (gc) != NULL)))
- {
- const GdkGCValuesMask blitting_mask = 0;
- GdkGCValuesMask drawing_mask = GDK_GC_FOREGROUND;
- gint ts_x_origin = 0, ts_y_origin = 0;
- cairo_rectangle_int_t region_extents;
-
- cairo_region_get_extents (region, ®ion_extents);
-
- GdkPixmap *mask_pixmap =
- gdk_pixmap_new (drawable, region_extents.width, region_extents.height, 1);
- GdkPixmap *tile_pixmap =
- gdk_pixmap_new (drawable, region_extents.width, region_extents.height, -1);
- GdkPixmap *stipple_bitmap = NULL;
- GdkColor fg;
-
- GdkGC *mask_gc = gdk_gc_new (mask_pixmap);
- GdkGC *tile_gc = gdk_gc_new (tile_pixmap);
-
- HDC mask_hdc;
- HDC tile_hdc;
-
- HGDIOBJ old_mask_hbm;
- HGDIOBJ old_tile_hbm;
-
- GdkGCValues gcvalues;
-
- hdc = gdk_win32_hdc_get (drawable, gc, blitting_mask);
- tile_hdc = CreateCompatibleDC (hdc);
-
- if (gcwin32->values_mask & GDK_GC_TS_X_ORIGIN)
- ts_x_origin = gc->ts_x_origin;
- if (gcwin32->values_mask & GDK_GC_TS_Y_ORIGIN)
- ts_y_origin = gc->ts_y_origin;
-
- ts_x_origin -= region_extents.x;
- ts_y_origin -= region_extents.y;
-
- /* Fill mask bitmap with zeros */
- gdk_gc_set_function (mask_gc, GDK_CLEAR);
- gdk_draw_rectangle (mask_pixmap, mask_gc, TRUE,
- 0, 0, region_extents.width, region_extents.height);
-
- /* Paint into mask bitmap, drawing ones */
- gdk_gc_set_function (mask_gc, GDK_COPY);
- fg.pixel = 1;
- gdk_gc_set_foreground (mask_gc, &fg);
-
- /* If the drawing function uses line attributes, set them as in
- * the real GC.
- */
- if (mask & LINE_ATTRIBUTES)
- {
- gdk_gc_get_values (gc, &gcvalues);
- if (gcvalues.line_width != 0 ||
- gcvalues.line_style != GDK_LINE_SOLID ||
- gcvalues.cap_style != GDK_CAP_BUTT ||
- gcvalues.join_style != GDK_JOIN_MITER)
- gdk_gc_set_line_attributes (mask_gc,
- gcvalues.line_width,
- gcvalues.line_style,
- gcvalues.cap_style,
- gcvalues.join_style);
- drawing_mask |= LINE_ATTRIBUTES;
- }
-
- mask_hdc = gdk_win32_hdc_get (mask_pixmap, mask_gc, drawing_mask);
- (*function) (GDK_GC_WIN32 (mask_gc), mask_hdc,
- region_extents.x, region_extents.y, args);
- gdk_win32_hdc_release (mask_pixmap, mask_gc, drawing_mask);
-
- if (fill_style == GDK_TILED)
- {
- /* Tile pixmap with tile */
- draw_tiles (tile_pixmap, tile_gc, SRCCOPY,
- _gdk_gc_get_tile (gc),
- 0, 0, ts_x_origin, ts_y_origin,
- region_extents.width, region_extents.height);
- }
- else
- {
- /* Tile with stipple */
- GdkGC *stipple_gc;
-
- stipple_bitmap =
- gdk_pixmap_new (NULL, region_extents.width, region_extents.height, 1);
- stipple_gc = gdk_gc_new (stipple_bitmap);
-
- /* Tile stipple bitmap */
- draw_tiles (stipple_bitmap, stipple_gc, SRCCOPY,
- _gdk_gc_get_stipple (gc),
- 0, 0, ts_x_origin, ts_y_origin,
- region_extents.width, region_extents.height);
-
- if (fill_style == GDK_OPAQUE_STIPPLED)
- {
- /* Fill tile pixmap with background */
- fg.pixel = _gdk_gc_get_bg_pixel (gc);
- gdk_gc_set_foreground (tile_gc, &fg);
- gdk_draw_rectangle (tile_pixmap, tile_gc, TRUE,
- 0, 0,
- region_extents.width, region_extents.height);
- }
- g_object_unref (stipple_gc);
- }
-
- g_object_unref (mask_gc);
- g_object_unref (tile_gc);
-
- mask_hdc = CreateCompatibleDC (hdc);
-
- if ((old_mask_hbm = SelectObject (mask_hdc, GDK_PIXMAP_HBITMAP (mask_pixmap))) == NULL)
- WIN32_GDI_FAILED ("SelectObject");
-
- if ((old_tile_hbm = SelectObject (tile_hdc, GDK_PIXMAP_HBITMAP (tile_pixmap))) == NULL)
- WIN32_GDI_FAILED ("SelectObject");
-
- if (fill_style == GDK_STIPPLED ||
- fill_style == GDK_OPAQUE_STIPPLED)
- {
- HDC stipple_hdc;
- HGDIOBJ old_stipple_hbm;
- HBRUSH fg_brush;
- HGDIOBJ old_tile_brush;
-
- if ((stipple_hdc = CreateCompatibleDC (hdc)) == NULL)
- WIN32_GDI_FAILED ("CreateCompatibleDC");
-
- if ((old_stipple_hbm =
- SelectObject (stipple_hdc,
- GDK_PIXMAP_HBITMAP (stipple_bitmap))) == NULL)
- WIN32_GDI_FAILED ("SelectObject");
-
- if ((fg_brush = CreateSolidBrush
- (_gdk_win32_colormap_color (impl->colormap,
- _gdk_gc_get_fg_pixel (gc)))) == NULL)
- WIN32_GDI_FAILED ("CreateSolidBrush");
-
- if ((old_tile_brush = SelectObject (tile_hdc, fg_brush)) == NULL)
- WIN32_GDI_FAILED ("SelectObject");
-
- /* Paint tile with foreround where stipple is one
- *
- * Desired ternary ROP: (P=foreground, S=stipple, D=destination)
- * P S D ?
- * 0 0 0 0
- * 0 0 1 1
- * 0 1 0 0
- * 0 1 1 0
- * 1 0 0 0
- * 1 0 1 1
- * 1 1 0 1
- * 1 1 1 1
- *
- * Reading bottom-up: 11100010 = 0xE2. PSDK docs say this is
- * known as DSPDxax, with hex value 0x00E20746.
- */
- GDI_CALL (BitBlt, (tile_hdc, 0, 0,
- region_extents.width, region_extents.height,
- stipple_hdc, 0, 0,
- ROP3_DSPDxax));
-
- if (fill_style == GDK_STIPPLED)
- {
- /* Punch holes in mask where stipple is zero */
- GDI_CALL (BitBlt, (mask_hdc, 0, 0,
- region_extents.width, region_extents.height,
- stipple_hdc, 0, 0,
- SRCAND));
- }
-
- GDI_CALL (SelectObject, (tile_hdc, old_tile_brush));
- GDI_CALL (DeleteObject, (fg_brush));
- GDI_CALL (SelectObject, (stipple_hdc, old_stipple_hbm));
- GDI_CALL (DeleteDC, (stipple_hdc));
- g_object_unref (stipple_bitmap);
- }
-
- /* Tile pixmap now contains the pattern that we should paint in
- * the areas where mask is one. (It is filled with said pattern.)
- */
-
- GDI_CALL (MaskBlt, (hdc, region_extents.x, region_extents.y,
- region_extents.width, region_extents.height,
- tile_hdc, 0, 0,
- GDK_PIXMAP_HBITMAP (mask_pixmap), 0, 0,
- MAKEROP4 (rop2_to_rop3 (gcwin32->rop2), ROP3_D)));
-
- /* Cleanup */
- GDI_CALL (SelectObject, (mask_hdc, old_mask_hbm));
- GDI_CALL (SelectObject, (tile_hdc, old_tile_hbm));
- GDI_CALL (DeleteDC, (mask_hdc));
- GDI_CALL (DeleteDC, (tile_hdc));
- g_object_unref (mask_pixmap);
- g_object_unref (tile_pixmap);
-
- gdk_win32_hdc_release (drawable, gc, blitting_mask);
- }
- else
- {
- hdc = gdk_win32_hdc_get (drawable, gc, mask);
- (*function) (gcwin32, hdc, 0, 0, args);
- gdk_win32_hdc_release (drawable, gc, mask);
- }
- va_end (args);
-}
-
static cairo_region_t *
widen_bounds (GdkRectangle *bounds,
gint pen_width)
return cairo_region_create_rectangle (bounds);
}
-static void
-draw_rectangle (GdkGCWin32 *gcwin32,
- HDC hdc,
- gint x_offset,
- gint y_offset,
- va_list args)
-{
- HGDIOBJ old_pen_or_brush;
- gboolean filled;
- gint x;
- gint y;
- gint width;
- gint height;
-
- filled = va_arg (args, gboolean);
- x = va_arg (args, gint);
- y = va_arg (args, gint);
- width = va_arg (args, gint);
- height = va_arg (args, gint);
-
- x -= x_offset;
- y -= y_offset;
-
- if (!filled && MUST_RENDER_DASHES_MANUALLY (gcwin32))
- {
- render_line_vertical (gcwin32, x, y, y+height+1) &&
- render_line_horizontal (gcwin32, x, x+width+1, y) &&
- render_line_vertical (gcwin32, x+width+1, y, y+height+1) &&
- render_line_horizontal (gcwin32, x, x+width+1, y+height+1);
- }
- else
- {
- if (filled)
- old_pen_or_brush = SelectObject (hdc, GetStockObject (NULL_PEN));
- else
- old_pen_or_brush = SelectObject (hdc, GetStockObject (HOLLOW_BRUSH));
- if (old_pen_or_brush == NULL)
- WIN32_GDI_FAILED ("SelectObject");
- else
- GDI_CALL (Rectangle, (hdc, x, y, x+width+1, y+height+1));
-
- if (old_pen_or_brush != NULL)
- GDI_CALL (SelectObject, (hdc, old_pen_or_brush));
- }
-}
-
-static void
-gdk_win32_draw_rectangle (GdkDrawable *drawable,
- GdkGC *gc,
- gboolean filled,
- gint x,
- gint y,
- gint width,
- gint height)
-{
- GdkRectangle bounds;
- cairo_region_t *region;
-
- GDK_NOTE (DRAW, g_print ("gdk_win32_draw_rectangle: %s (%p) %s%dx%d@%+d%+d\n",
- _gdk_win32_drawable_description (drawable),
- gc,
- (filled ? "fill " : ""),
- width, height, x, y));
-
- bounds.x = x;
- bounds.y = y;
- bounds.width = width;
- bounds.height = height;
- region = widen_bounds (&bounds, GDK_GC_WIN32 (gc)->pen_width);
-
- generic_draw (drawable, gc,
- GDK_GC_FOREGROUND | GDK_GC_BACKGROUND |
- (filled ? 0 : LINE_ATTRIBUTES),
- draw_rectangle, region, filled, x, y, width, height);
-
- cairo_region_destroy (region);
-}
-
static void
gdk_win32_draw_drawable (GdkDrawable *drawable,
GdkGC *gc,